package web.javas.service.impl;

import org.apache.ibatis.session.SqlSession;
import web.javas.entity.User;
import web.javas.mapper.UserMapper;
import web.javas.service.UserService;
import web.javas.util.MybatisUtil;

public class UserServiceImpl implements UserService {
	SqlSession sqlSession= MybatisUtil.getSqlSession();
	UserMapper userMapper= sqlSession.getMapper(UserMapper.class);
	@Override
	public User login(String username, String password) {
		User user=userMapper.findUserByName(username);
		if(user != null){
			if(user.getPassword().equals(password)){
				return user;
			}
		}
		return null;
	}

	@Override
	public String getUserType(String username) {
		String usertype=userMapper.getUserType(username);
		return usertype;
	}

	@Override
	public User getUserById(int id) {
		User user=userMapper.getUserById(id);
		return user;
	}
}
